package com.tbit.uqbike.client.service.impl;

import com.tbit.common.constant.BusinessConstant;
import com.tbit.common.constant.PayPlatformContent;
import com.tbit.common.entity.UserCapitalChange;
import com.tbit.uqbike.client.dao.capital.UserCapitalChangeDao;
import com.tbit.uqbike.client.service.UserCapitalChangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: chen
 * @Description:
 * @Date: 创建于 11:14 2022/11/30
 */
@Service
public class UserCapitalChangeServiceImpl implements UserCapitalChangeService {
    @Autowired
    private UserCapitalChangeDao userCapitalChangeDao;

    @Override
    public List<UserCapitalChange> getUserCapitalChange(Integer userId) {

        List<UserCapitalChange> userCapitalChanges = userCapitalChangeDao.getByUserId(userId);

        if (!userCapitalChanges.isEmpty()) {
            for (UserCapitalChange u : userCapitalChanges) {
                if (BusinessConstant.TransList.contains(u.getBusinessType())) {
                    if (u.getChangeType().equals(PayPlatformContent.PAY_RECHARGE)) {
                        u.setChangeType(PayPlatformContent.PAY_USE);
                    } else {
                        u.setChangeType(PayPlatformContent.PAY_RECHARGE);
                    }
                }
            }
        }
        return userCapitalChanges;
    }
}
